package org.bpms.service.wechat;

import java.util.List;

import org.bpms.model.wechat.Weixin;

import com.jfinal.aop.Before;
import com.jfinal.plugin.activerecord.tx.Tx;

/**
 * 微信业务处理
 * @author hupei
 *
 */
public class WeixinService {
	/**
	 * 保存微信基本设置
	 * @param weixin
	 * @return
	 */
	@Before(Tx.class)
	public Weixin saveOrUpdate(Weixin weixin){
		if (null != weixin.getInt("id")){
			weixin.update();
		}else{
			weixin.save();
		}
		return weixin;
	}
	
	/**
	 * 获取微信基础设置
	 * @return
	 */
	public Weixin find(){
		List<Weixin> lw = Weixin.me.find("select * from weixin");
		if (null != lw && lw.size() > 0){
			return lw.get(0);
		}
		return null;
	}
}
